package com.lhd.ivos.audit.controller;

import com.lhd.ivos.audit.pojo.dto.AuditQuery;
import com.lhd.ivos.audit.pojo.dto.AuditSaveParam;
import com.lhd.ivos.audit.pojo.vo.AuditVO;
import com.lhd.ivos.audit.service.AuditService;
import com.lhd.ivos.base.response.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author lhd
 * date 2024/5/27
 * @apiNote
 */
@Slf4j
@RestController
@RequestMapping("/v1/audit")
public class AuditController {

    @Autowired
    AuditService auditService;

    @GetMapping("select")
    public JsonResult selectAudit(AuditQuery auditQuery){
        log.debug("查询审批单:auditQuery={}",auditQuery);
        List<AuditVO> list = auditService.selectAudit(auditQuery);
        return JsonResult.ok(list);
    }

    // 注意：这里就只是更新审批单，新增审批单在新增申请单save()时就已经完成了
    @PostMapping("update")
    public JsonResult updateAudit(AuditSaveParam auditSaveParam){
        log.debug("更新审批单:auditSaveParam={}",auditSaveParam);
        auditService.updateAudit(auditSaveParam);
        return JsonResult.ok();
    }
}
